package Maze;

import java.util.Scanner;

public class MazeSolver {

    boolean wall = false;

    char[][] maze;

    boolean solved;

    int startX;

    int startY;

    int row;

    int col;

 

    public MazeSolver(char[][] in_maze) {

        maze = in_maze;

    }

 

    public void findPath(int row, int col) {

        if (maze[row][col] == 'T') {

            solved = true;

            return;

        }

 

        maze[row][col] = 'b';

 

        if (maze[row + 1][col] == ' ') {

            findPath(row + 1, col);

        }

        else if (maze[row][col + 1] == ' ') {

            findPath(row, col + 1);

        }

        else if (maze[row - 1][col] == ' ') {

            findPath(row -1, col);

        }

        else if (maze[row][col - 1] == ' ') {

            findPath(row, col - 1);

        }

        else {

            wall = true;

            return;

        }

 

        if (wall) {

            wall = false;

            findPath(row, col);

        }

    }

 

    public void printMaze(int rows, int cols) {

        Scanner myScanner = new Scanner (System.in);

        for (int i = 0; i < rows; i++) {

            String nextLine = myScanner.nextLine();

            for (int j = 0; j < cols; j++) {

                char nextChar = nextLine.charAt(j);

                maze[i][j] = nextChar;

                System.out.print(nextChar);

            }

        }

    }

}
